/**
 * 
 */
package com.feonix.io;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @CopyRight (c)1993-2017
 * @Project common_practice
 * @Comments 获取输入流，读取为  byte[] 数组
 * @NameSpace com.feonix.io
 * @Author Feonixzw
 * @CreateDate 2017年12月6日
 */
public class IOTest1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		InputStream is = null;
		ByteArrayOutputStream baos = null;
		byte[] buffer = null;
		int length = 0;
		int bufferSize = 0;
		try {
			baos = new ByteArrayOutputStream();
			is = new FileInputStream(new File("C:/Users/Administrator/Desktop/1.jpg"));
			bufferSize = is.available();
			buffer = new byte[bufferSize];
			while((length = is.read(buffer, 0, bufferSize))!=-1){
				baos.write(buffer, 0, length);
			}
			System.out.println(baos.toByteArray().length);
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			try {
				is.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
